package itheima.d03;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        String[] selects={"大明湖","趵突泉","千佛山","黑虎泉"};
        List<String> datas =new ArrayList<>();
        Random random = new Random();
        for (int i = 1; i < 80; i++) {
            int index = random.nextInt(selects.length);
            datas.add(selects[index]);

        }
        datas.forEach(System.out::println);
        System.out.println("===========================");


        Map<String,Integer> map = new HashMap<>();
        for (String data : datas) {
            if(map.containsKey(data)){
                Integer count = map.get(data);
                map.put(data,count+1);
            }else{
                map.put(data,1);
            }
        }

        for (String data : datas) {
            map.merge(data,1,(oldValue,newValue)->oldValue+newValue);
        }
        map.forEach((k,v)-> System.out.println(k+"---"+v));
    }
}
